// Node.cpp: implementation of the Node class.
//
//////////////////////////////////////////////////////////////////////

#include "Node.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

NodeState::NodeState()
{

}

NodeState::~NodeState()
{
}


bool NodeState::operator<(const NodeState &secNode) const 
{
	unsigned char firstF = hValue + gValue;
	unsigned char secF = secNode.hValue + secNode.gValue;

	if (firstF < secF) //first better then sec
		return false;
	if (firstF == secF && (gValue > secNode.gValue))
		return false;
	return true;

}

void NodeState::operator=(const NodeState &secNode)
{
	gValue = secNode.gValue ;
	hValue = secNode.hValue ;
	for (int i=0;i<SIZE;i++)
		state[i] = secNode.state[i];

}


void NodeState::Initialize(int *arr,unsigned char gVal,unsigned char hVal)
{
	gValue = gVal ;
	hValue = hVal ;

	for (int i=0;i<SIZE;i++)
		state[i] = arr[i];
}


void NodeState::Print()
{
//	for (int i =0;i< SIZE; i++)
//		printf("%d ",state[i]);
	printf("\tg=%d h=%d f=%d \n",gValue ,hValue ,F() );

}
